package com.qimo.zuoyeoa.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qimo.zuoyeoa.dao.JobLoginMapper;
import com.qimo.zuoyeoa.entity.JobLogin;
import com.qimo.zuoyeoa.service.JobLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class JobLoginServiceImpl implements JobLoginService{
    @Autowired
    private JobLoginMapper jobLoginMapper;




    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean append(JobLogin jobLogin) {
        return jobLoginMapper.insert(jobLogin) > 0;
    }

    @Override
    public PageInfo<JobLogin> findAll(int pageNum, int pageSize) {

        PageHelper.startPage(pageNum,pageSize);
        final List<JobLogin> jobLogins = jobLoginMapper.selectAll();
        PageInfo<JobLogin> pageInfo = new PageInfo<>(jobLogins);
        return pageInfo;
    }

    @Override
    public PageInfo<JobLogin> findByKeyword(int pageNum, int pageSize, String keyword) {
        PageHelper.startPage(pageNum, pageSize);
        List<JobLogin> jobLogins = jobLoginMapper.selectByKeyword(keyword);
        PageInfo<JobLogin> pageInfo = new PageInfo<>(jobLogins);
        return pageInfo;
    }

    @Override
    public JobLogin findById(int id) {
        return jobLoginMapper.selectById(id);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean modify(JobLogin jobLogin) {
        return jobLoginMapper.updateById(jobLogin)>0;
    }


    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean remove(int id) {
        return jobLoginMapper.deleteById(id) > 0;
    }

    @Override
    public List<JobLogin> findAll() {
        return jobLoginMapper.selectAll();
    }
}
